package cn.hnwlgc.controller;

import cn.hnwlgc.pojo.Result;
import cn.hnwlgc.pojo.User;
import cn.hnwlgc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin(origins = "*")
public class LoginController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public Result login(@RequestBody User user){
        User u=userService.login(user);
        return u!=null?Result.success(u):Result.error("用户名或密码错误");
    }
}
